package com.ap.core.dao.impl;

import org.hibernate.Criteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;

import com.ap.core.dao.AbstractReadOnlyAPCoreBaseJpaDao;
import com.ap.core.dao.FinancialInstitutionDao;
import com.ap.core.domain.FinancialInstitution;

/**
 * User: Rohit.Dixit
 * Jpa Implementation class for {@link com.ap.core.dao.FinancialInstitutionDao}
 */
public class JpaFinancialInstitutionDao extends AbstractReadOnlyAPCoreBaseJpaDao<FinancialInstitution, Long> implements FinancialInstitutionDao{

    @Override
    public FinancialInstitution findById(Long primaryKey) {
        return findById(FinancialInstitution.class, primaryKey);
    }
    
    @Override
	public FinancialInstitution getFIByIdentification(String fiIdentification) {
        Criteria criteria = getSession().createCriteria(FinancialInstitution.class);
        criteria.add(Restrictions.eq("fiIdentification", fiIdentification));
        criteria.setMaxResults(1);
        criteria.addOrder(Order.desc("id"));
        return (FinancialInstitution)criteria.uniqueResult();
	}

}
